package top.fengleifeng.question;

/**
 * @program: leetcode-test
 * @description:
 * @author: fengleifeng
 * @create: 2020-10-09 16:08
 **/
public class Num1503所有蚂蚁掉下来前的最后一刻 {
    class Solution {
        public int getLastMoment(int n, int[] left, int[] right) {
            int result = 0;
            int leftMax = Integer.MIN_VALUE;
            int rightMin = Integer.MAX_VALUE;
            for (int i = 0; i < left.length; i++) {
                leftMax = Math.max(leftMax, left[i]);
            }
            for (int i = 0; i < right.length; i++) {
                rightMin = Math.min(rightMin, right[i]);
            }
            int leftresult = leftMax;
            int rightresult = n - rightMin;
            result = Math.max(leftresult, rightresult);
            return result;
        }
    }

    public static void main(String[] args) {
        int i = 4;
        int[] ints = {4, 3};
        int[] ints1 = {0, 1};
        int lastMoment = new Num1503所有蚂蚁掉下来前的最后一刻().new Solution().getLastMoment(i, ints, ints1);
        System.out.println(lastMoment);
    }
}
